echo "* soft nofile 51200">>/etc/security/limits.conf

echo "* hard nofile 51200">>/etc/security/limits.conf

echo "session required pam_limits.so">>/etc/pam.d/common-session

echo "ulimit -SHn 51200">>/etc/profile

sed -i 's/http:\/\/.*.ubuntu.com/http:\/\/mirrors.tuna.tsinghua.edu.cn/' /etc/apt/sources.list

apt update && apt upgrade -y

apt-get install git zsh curl unzip vim -y

apt install -y apt-transport-https ca-certificates software-properties-common

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

apt-key fingerprint 0EBFCD88

add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

echo "安装 install docker"

apt install -y docker-ce

echo "启动 docker ..."

service docker start

#创建文件
mkdir -p /data/docker/lib
# 同步
rsync -avz /var/lib/docker /data/docker/lib

touch /etc/docker/daemon.json

echo '{"data-root": "/data/docker/lib"}' > /etc/docker/daemon.json

echo "重启 docker ...."
service docker restart

echo "创建 traefik 网卡"
docker network create traefik

#github
# curl -L https://github.com/docker/compose/releases/download/1.25.3/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
#微软
# curl -L http://mirror.azure.cn/docker-toolbox/linux/compose/1.25.4/docker-compose-Linux-x86_64 -o /usr/local/bin/docker-compose

mkdir ~/halobug && cd ~/halobug
echo "安装 docker compose"

git clone https://gitee.com/halobug/bash.halobug.cn.git && cd ~/halobug/bash.halobug.cn/file/ && cp docker-compose-Linux-x86_64 /usr/local/bin/docker-compose

chmod +x /usr/local/bin/docker-compose

#运行traefik
echo "run traefik ..."
cd ~/halobug && git clone https://gitee.com/halobug/traefik.halobug.cn.git && cd ~/halobug/traefik.halobug.cn

bash ca.sh && docker-compose down && docker-compose up -d

echo "运行完毕，新机器初始化完毕！"

echo "更换shell"
curl -L http://install.ohmyz.sh | sh

chsh -s /bin/zsh
